/* ====================================================================
 * (#)Header: JmsMessageListener.java
 * (#)Revision: 
 * (#)Date Created: 02-Nov-09 10:32:15 AM
 * (#)Created By: Karol Wozniak
 * ====================================================================
 *
 * Copyright (c) 2007 karolak .  All rights reserved.
 *
 * ====================================================================
 * 
 * The software application represented here is the sole property of 
 * karolak. Its unauthorized utilization is expressly prohibited.
 * 
 * ====================================================================
 */
package com.karolak.jms;

import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import javax.jms.TextMessage;

/**
 * <code>JmsMessageListener</code> is used to ....
 * 
 * @author <a href="mailto:kwozniak@hotmail.com">Karol Wozniak</a>
 */
public class JmsMessageListener implements MessageListener {
	public void onMessage(Message message) {
		if (message instanceof TextMessage) {
			onTextMessage((TextMessage) message);
		} else if (message instanceof ObjectMessage) {
			onObjectMessage((ObjectMessage) message);
		} else {
			System.out.println("Received message: " + message);
		}
	}

	protected void onTextMessage(TextMessage message) {
		try {
			System.out.println("Received TextMessage: " + message.getText());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	protected void onObjectMessage(ObjectMessage message) {
		try {
			System.out.println("Received ObjectMessage: " + message);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
